package cn.sumpu.app.coolsk.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.sumpu.app.coolsk.dao.CompanyOrderDao;
import cn.sumpu.app.coolsk.domain.Order;
import cn.sumpu.app.coolsk.exception.AppBusinessException;

public class CompanyOrderDaoImpl extends SqlSessionDaoSupport implements CompanyOrderDao{
	private static Logger logger = LoggerFactory.getLogger(CompanyOrderDaoImpl.class);

	@SuppressWarnings("unchecked")
	@Override
	public List<Order> getCompanyOrder(Map<String, Object> map)
			throws AppBusinessException {
		try {
			   return getSqlSession().selectList("cn.sumpu.app.coolsk.persistence.CompanyOrderMapper.getCompanyOrder",map);
			} catch (Exception e) {
				if (logger.isErrorEnabled()) {
					logger.error("getCompanyOrder failure.", e);
				}
				throw new AppBusinessException("getCompanyOrder failure.", e);
			}
	}

	@Override
	public int getCompanyOrderCount(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return (Integer) getSqlSession().selectOne("cn.sumpu.app.coolsk.persistence.CompanyOrderMapper.getCompanyOrderCount", map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getCompanyOrderCount failure.", e);
			}
			throw new AppBusinessException("getCompanyOrderCount failure.", e);
		}
		
	}
}
